<?php

/**
 * This is the model class for table "ref_area".
 *
 * The followings are the available columns in table 'ref_area':
 * @property string $area_id
 * @property string $area_par_id
 * @property string $area_name
 * @property string $area_latitude
 * @property string $area_longitude
 * @property string $area_is_active
 */
class ref_area extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return ref_area the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'ref_area';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('area_par_id', 'length', 'max' => 10),
            array('area_name', 'length', 'max' => 100),
            array('area_latitude, area_longitude', 'length', 'max' => 25),
            array('area_is_active', 'length', 'max' => 1),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('area_id, area_par_id, area_name, area_latitude, area_longitude, area_is_active', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'area_id' => 'Area',
            'area_par_id' => 'Parent',
            'area_name' => 'Area Name',
            'area_latitude' => 'Latitude',
            'area_longitude' => 'Longitude',
            'area_is_active' => 'Is Active',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('area_id', $this->area_id, true);
        $criteria->compare('area_par_id', $this->area_par_id, true);
        $criteria->compare('area_name', $this->area_name, true);
        $criteria->compare('area_latitude', $this->area_latitude, true);
        $criteria->compare('area_longitude', $this->area_longitude, true);
        $criteria->compare('area_is_active', $this->area_is_active, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}